//
//  WHHeaderCollectionReusableView.m
//  GroupFourFM
//
//  Created by dllo on 15/12/22.
//  Copyright © 2015年 GroupFour. All rights reserved.
//

#import "WHHeaderCollectionReusableView.h"

@implementation WHHeaderCollectionReusableView


-(instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    if (self){
        
        [self createBtn];
    }
    
    return self;
    
}

-(void)createBtn{
    self.soundBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.soundBtn setBackgroundImage:[UIImage imageNamed:@"tushu"] forState:UIControlStateNormal];
    [self addSubview:self.soundBtn];
    
#pragma mark - 约束
    
    [self.soundBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.top.mas_equalTo(@10);
        make.width.mas_equalTo(@(SCREEN_WIDTH/2-10));
        //make.height.mas_equalTo(@(SCREEN_WIDTH/2-15));
        make.bottom.mas_equalTo(@-10);
    }];
    
    self.musciBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.musciBtn setBackgroundImage:[UIImage imageNamed:@"yinyue"] forState:UIControlStateNormal];
    [self addSubview:self.musciBtn];
    
    [self.musciBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.soundBtn.mas_right).offset(5);
        make.top.equalTo(self.soundBtn);
        make.width.mas_equalTo(@(SCREEN_WIDTH/4-10));
        make.height.mas_equalTo(@(SCREEN_WIDTH/4-10));
        
    }];
    
    self.yuleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.yuleBtn setBackgroundImage:[UIImage imageNamed:@"yule"] forState:UIControlStateNormal];
    [self addSubview:self.yuleBtn];
    
    [self.yuleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.musciBtn.mas_right).offset(5);
        make.top.equalTo(self.soundBtn);
        make.width.mas_equalTo(@(SCREEN_WIDTH/4-10));
        make.height.mas_equalTo(@(SCREEN_WIDTH/4-10));
        
    }];
    
    
    self.xiangShBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self addSubview:self.xiangShBtn];
    [self.xiangShBtn setBackgroundImage:[UIImage imageNamed:@"xiaoyuan"] forState:UIControlStateNormal];
    
    [self.xiangShBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.soundBtn.mas_right).offset(5);
        make.top.equalTo(self.musciBtn.mas_bottom).offset(5);
        make.width.mas_equalTo(@(SCREEN_WIDTH/4-10));
        make.bottom.mas_equalTo(@(-10));
        
    }];
    
    self.childBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self addSubview:self.childBtn];
    [self.childBtn setBackgroundImage:[UIImage imageNamed:@"qinggan"] forState:UIControlStateNormal];
    
    [self.childBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.xiangShBtn.mas_right).offset(5);
        make.top.equalTo(self.xiangShBtn);
        make.width.mas_equalTo(@(SCREEN_WIDTH/4-10));
        make.bottom.mas_equalTo(@(-10));
        
    }];
    
    self.soundBtn.tag = 10001;
    [self.soundBtn addTarget:self action:@selector(put:) forControlEvents:UIControlEventTouchUpInside];
    self.musciBtn.tag = 10002;
    [self.musciBtn addTarget:self action:@selector(put:) forControlEvents:UIControlEventTouchUpInside];
    self.yuleBtn.tag = 10003;
    [self.yuleBtn addTarget:self action:@selector(put:) forControlEvents:UIControlEventTouchUpInside];
    self.xiangShBtn.tag = 10004;
    [self.xiangShBtn addTarget:self action:@selector(put:) forControlEvents:UIControlEventTouchUpInside];
    self.childBtn.tag = 10005;
    [self.childBtn addTarget:self action:@selector(put:) forControlEvents:UIControlEventTouchUpInside];
    
    
    
}

-(void)put:(UIButton *)btn{
    
    [self.buttonDelegate pushToMusic:btn.tag];
    
}

@end
